const int N = 5E4 + 5;

struct BigInt {
    int a[N];
    BigInt(int x = 0) : a{} {
        for (int i = 0; x; ++i) {
            a[i] = x % 10;
            x /= 10;
        }
    }
    BigInt(const BigInt &x) {
        std::memcpy(a, x.a, sizeof a);
    }
    BigInt &operator*=(int x) {
        for (int i = 0; i < N; ++i) {
            a[i] *= x;
        }
        for (int i = 0; i < N - 1; ++i) {
            a[i + 1] += a[i] / 10;
            a[i] %= 10;
        }
        return *this;
    }
    BigInt &operator/=(int x) {
        for (int i = N - 1; i >= 0; --i) {
            if (i) {
                a[i - 1] += a[i] % x * 10;
            }
            a[i] /= x;
        }
        return *this;
    }
    BigInt operator/(int x) {
        BigInt t(*this);
        return t /= x;
    }
    BigInt &operator+=(const BigInt &x) {
        for (int i = 0; i < N; ++i) {
            a[i] += x.a[i];
            if (a[i] >= 10) {
                a[i + 1] += 1;
                a[i] -= 10;
            }
        }
        return *this;
    }
    bool operator<(const BigInt &x) {
        int t = N - 1;
        while (t >= 0 && a[t] == x.a[t]) {
            --t;
        }
        return t >= 0 && a[t] < x.a[t];
    }
};

std::ostream &operator<<(std::ostream &os, const BigInt &a) {
    int t = N - 1;
    while (t > 0 && a.a[t] == 0) {
        --t;
    }
    for (int i = t; i >= 0; --i) {
        os << a.a[i];
    }
    return os;
}

void chmax(BigInt &x, BigInt a) {
    if (x < a) {
        x = a;
    }
}